$(function(){
	
	
	function petsShowCategory(flag,big){
		// 1,big   2,small
		$.getJSON('../../ShowCg.do',{
			flag:flag,
			bigcategory:big
		},function(data,status){
			if(status){
				if(flag == '1' || flag == 1){
					$('.add-big-category').empty();
					for(var i = 0; i< data.length ;i++){
						$('.add-big-category').append('<option>'+data[i].NAME+'</option>');
					}
				}else{
					$('.add-small-category').empty();
					for(var i = 0; i< data.length ;i++){
						$('.add-small-category').append('<option>'+data[i].NAME+'</option>');
					}
				}
			}
		});
	}
	
	
	petsShowCategory(1,0);
	petsShowCategory(2,'狗');
	
	$('.add-big-category').change(function(){
		var pet = $('.add-big-category').val();
		petsShowCategory(2,pet);
	});
	
	
	
	
	
	function checkAddForm(){
		
		var boo = false;
		
		$('#add-pet-name').on('blur',function(){
			
			function a(){
				if($('#add-pet-name').val()==''){
					$('#add-pet-name').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-name').focus(function(){
			$('#add-pet-name').val('');
		});
		
		
		
		$('#add-pet-nickname').on('blur',function(){
			
			function a(){
				if($('#add-pet-nickname').val()==''){
					$('#add-pet-nickname').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-nickname').focus(function(){
			$('#add-pet-nickname').val('');
		});
		
		
		
		$('#add-pet-age').on('blur',function(){
			
			function a(){
				if($('#add-pet-age').val()==''){
					$('#add-pet-age').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-age').focus(function(){
			$('#add-pet-age').val('');
		});
		
		
		
		$('#add-pet-weight').on('blur',function(){
			
			function a(){
				if($('#add-pet-weight').val()==''){
					$('#add-pet-weight').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-weight').focus(function(){
			$('#add-pet-weight').val('');
		});
		
		
		
		$('#add-pet-color').on('blur',function(){
			
			function a(){
				if($('#add-pet-color').val()==''){
					$('#add-pet-color').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-color').focus(function(){
			$('#add-pet-color').val('');
		});
		
		
		
		$('#add-pet-costprice').on('blur',function(){
			
			function a(){
				if($('#add-pet-costprice').val()==''){
					$('#add-pet-costprice').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-costprice').focus(function(){
			$('#add-pet-costprice').val('');
		});
		
		

		
		
		
		
		$('#add-pet-address').on('blur',function(){
			
			function a(){
				if($('#add-pet-address').val()==''){
					$('#add-pet-address').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-address').focus(function(){
			$('#add-pet-address').val('');
		});
		
		
		
		
		$('#add-pet-price').on('blur',function(){
			
			function a(){
				if($('#add-pet-price').val()==''){
					$('#add-pet-price').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-price').focus(function(){
			$('#add-pet-price').val('');
		});
		
		
		
		
		$('#add-pet-introduce').on('blur',function(){
			
			function a(){
				if($('#add-pet-introduce').val()==''){
					$('#add-pet-introduce').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-introduce').focus(function(){
			$('#add-pet-introduce').val('');
		});
		
		
		
		
		$('#add-pet-specialprice').on('blur',function(){
			
			function a(){
				if($('#add-pet-specialprice').val()==''){
					$('#add-pet-specialprice').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-specialprice').focus(function(){
			$('#add-pet-specialprice').val('');
		});
		
		
		$('#add-pet-count').on('blur',function(){
			
			function a(){
				if($('#add-pet-count').val()==''){
					$('#add-pet-count').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-count').focus(function(){
			$('#add-pet-count').val('');
		});
		
		
		
		
		$('#add-pet-image01').on('blur',function(){
			
			function a(){
				if($('#add-pet-image01').val()==''){
					$('#add-pet-image01').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-image01').focus(function(){
			$('#add-pet-image01').val('');
		});
		
		
		
		
		$('#add-pet-image02').on('blur',function(){
			
			function a(){
				if($('#add-pet-image02').val()==''){
					$('#add-pet-image02').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-image02').focus(function(){
			$('#add-pet-image02').val('');
		});
		
		
		
		
		$('#add-pet-image03').on('blur',function(){
			
			function a(){
				if($('#add-pet-image03').val()==''){
					$('#add-pet-image03').val('请输入内容!!!');
					return false;
				}
				return true;
			}
			
			boo = a();
			
		});
		
		$('#add-pet-image03').focus(function(){
			$('#add-pet-image03').val('');
		});
		
		
		return boo;
	}
	checkAddForm();
	
	$('#add-btn').click(function(){
//		console.log(checkAddForm());
		
		$('#pet-add-form').submit();
		
	});
	
	$('#info-btn').click(function(){
		
		$('#pet-info-form').submit();
		
	});
	
	$('#img-btn').click(function(){
		
		$('#up-img-form').submit();
		
	});
	

})
	//time
	$(function(){
		
		var mydate = new Date();
		var time = mydate.getFullYear()+'-'+mydate.getMonth()+'-'+mydate.getDate()+' '+mydate.getHours()+':'+mydate.getMinutes()+':00';
		$('#add-pet-date').val(time);
	})
	